package com.cy.store.entity;

import java.io.Serializable;
import java.util.Objects;

/**
 * 用户的实体类
 * 1、get() & set()
 * 2、equals() & hashCode()
 */

public class User extends BaseEntity implements Serializable {
    private int uid;// INT AUTO_INCREMENT COMMENT '用户id',
    private String username;// VARCHAR(20) NOT NULL UNIQUE COMMENT '用户名',
    private String password;// CHAR(32) NOT NULL COMMENT '密码',
    private String salt;// CHAR(36) COMMENT '盐值',
    private String phone;// VARCHAR(20) COMMENT '电话号码',
    private String email;// VARCHAR(30) COMMENT '电子邮箱',
    private int gender;// INT COMMENT '性别:0-女，1-男',
    private String avatar;// VARCHAR(50) COMMENT '头像',
    private int isDelete;// INT COMMENT '是否删除：0-未删除，1-已删除',

    public User() {
    }

    public User(int uid, String username, String avatar) {
        this.uid = uid;
        this.username = username;
        this.avatar = avatar;
    }

    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public int getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(int isDelete) {
        this.isDelete = isDelete;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        User user = (User) o;
        return uid == user.uid && gender == user.gender && isDelete == user.isDelete && Objects.equals(username, user.username) && Objects.equals(password, user.password) && Objects.equals(salt, user.salt) && Objects.equals(phone, user.phone) && Objects.equals(email, user.email) && Objects.equals(avatar, user.avatar);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), uid, username, password, salt, phone, email, gender, avatar, isDelete);
    }

    @Override
    public String toString() {
        return "User{" +
                "uid=" + uid +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", salt='" + salt + '\'' +
                ", phone='" + phone + '\'' +
                ", email='" + email + '\'' +
                ", gender=" + gender +
                ", avatar='" + avatar + '\'' +
                ", isDelete=" + isDelete +
                '}';
    }
}
